// var Api = "http://songyujianiu.qicp.vip/";
var Api = "http://localhost:9000";
var app = new Vue({
	el: "#app",
	data: function() {
		return {
			loginName: "",
			equipId: "",
			equipName: "",
			addTime: "",
		};
	},
	created: function() {
		this.finduserbyid();
	},
	methods: {
		// 查询用户model
		findEquipById : function() {
			/* alert(this.uid); */
			let that = this;
			const par = new URLSearchParams();
			par.append("id")
			axios({
				method: "post",
				url: Api + "/equip/findEquipById",
				params: par,
			}).then(function(res) {
				/* console.log(res); */
				if (res.data.code == "101") {
					that.loginName = res.data.data.loginName;
					that.equipId = res.data. data.equipId;
					that.equipName = res.data.data.equipName;
					that.addTime = res.data.data.addTime;
					time: 1000
				} else {
					layer.msg(res.data.message, {
						time: 1000
					});
				}
			});
		},
		// 保存
		updateEquip: function() {
			let that = this;
			console.log("app");
			const par = new URLSearchParams();
			par.append("loginName", that.loginName);
			par.append("equipId", that.equipId);
			par.append("equipName", that.equipName);
			par.append("addTime", that.addTime);
			axios({
				method: "post",
				url: Api + "/users/updateuser",
				params: par,
			}).then(function(res) {
				console.log(res);
				if (res.data.code == "101") {
					// alert("注册成功");
					layer.msg("修改成功", {
						time: 1000
					});
					window.location.href = "index.html";
				} else {
					layer.msg(res.data.message, {
						time: 1000
					});
				}
			});
		},
		//  弹出框的全选
		handleSelectionChange(val) {
			console.log(val);
			var arr = [];
			let that = this;
			for (const item in val) {
				arr.push(val[item].userId);
			}
			that.userId = arr;
		},
		//  分页
		handleSizeChange(val) {
			console.log(`每页 ${val} 条`);
		},
		handleCurrentChange(val) {
			console.log(`当前页: ${val}`);
		},
	},
});
